package com.example.day06.ex02;

import java.util.Scanner;

public class Test10 {
    public static void main(String[] args) {
        int[]arr=new int[6];
        Scanner sc=new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个评委打的分：");
            arr[i]=sc.nextInt();
        }
        int max=getMax(arr);
        int min=getMin(arr);
        int sum=getSum(arr);
        int avg=(sum-max-min)/(arr.length)-2;
        System.out.println("最终成绩为："+avg);
    }
    public static int getMax(int[] arr) {
        int max=arr[0];
        for (int i = 1; i < arr.length; i++){
            if (arr[i]>max){
                max=arr[i];
            }
        }
        return max;
    }
    public static int getMin(int[] arr) {
        int min=arr[0];
        for (int i = 1; i < arr.length; i++){
            if (arr[i]<min){
                min=arr[i];
            }
        }
        return min;
    }
    public static int getSum(int[] arr) {
        int sum=0;
        for (int i = 0; i < arr.length; i++){
            sum+=arr[i];
        }
        return sum;
    }
    public static void printArray(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i==arr.length-1){
                System.out.print(arr[i]+"]");
            }else {
                System.out.print(arr[i]+",");
            }
        }
        System.out.print("]");
    }
}
